<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content"><?php echo $content_top; ?>  
  <h1><?php echo $heading_title; ?></h1>  
  <?php if ($products) { ?> 
    
  <!-- <div class="product-grid">
    <?php foreach ($products as $product) { ?>
    <div>
      <?php if ($product['thumb']) { ?>
      <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
      <?php } ?>
      <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></div>
      <div class="description"><?php echo $product['description']; ?></div>
      <?php if ($product['price']) { ?>
      <div class="price">
        <?php if (!$product['special']) { ?>
        <?php echo $product['price']; ?>
        <?php } else { ?>
        <span class="price-old"><?php echo $product['price']; ?></span> <span class="price-new"><?php echo $product['special']; ?></span>
        <?php } ?>
        <?php if ($product['tax']) { ?>
        <br />
        <span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
        <?php } ?>
      </div>
      <?php } ?>      
    </div>
    <?php } ?>
  </div>  
   -->
   
    <div class="box_center box_product box_danhmuc clearfix">											
		<div id="postswrapper" class="content clearfix">
            <div class="with_109">
            <?php foreach ($products as $product):?>
			<div class="items_danhmuc clearfix">
				<a href="<?php echo $product['href']?>" class="img_items_danhmuc clearfix">
					<img src="<?php echo $product['thumb']?>" width="218" height="207" />
				</a>
                <?php if($product['special'] && $product['price'] != 0 && $product['price'] > $product['special']):?>
                	<span class="icon_down"><span class="text_ration"><?php echo ceil((($product['price']-$product['special'])/$product['price'])*100)."%";?></span></span>
                <?php endif;?>
                <h2 class="h2_items_danhmuc"><a href="<?php echo $product['href']?>" class="name_items_danhmuc"><?php echo $product['name']?><br /><small>Bộ sưu tập đèn ngủ với lối thiết kế trang nhã nhẹ nhàng , dễ chịu </small></a></h2>
                <?php if (!$product['special']):?>
                	<span class="sp_price"><?php echo $product['price']?></span>
                <?php else:?>
	                <span class="sp_price_off "><?php echo $product['price'];?></span>
					<span class="sp_price"><?php echo $product['special']?></span>
                <?php endif;?>														
            </div><!--end items_danhmuc-->                                                                 
            <?php endforeach;?>         
            </div>   
		</div><!--end content-->
		<div><img id="loadmoreajaxloader" style="display:none" src="../catalog/view/theme/default/image/ajaxLoading.gif"/></div>
	</div><!--end box_product-->
  <?php } else { ?>
  <div class="content"><?php echo $text_empty; ?></div>
  <?php }?>
  <?php echo $content_bottom; ?></div> 
<?php echo $footer; ?>

<script type="text/javascript">
var page = 1;
var per_page = <?php echo $per_page;?>;
$(window).scroll(function()
{	
    if($(window).scrollTop() == $(document).height() - $(window).height())
    {
        page++;        
        if(page<(per_page +1)){
	        $('div#loadmoreajaxloader').show();
	        $.ajax({
	        url: 'index.php?route=product/search/load_ajax&filter_name=<?php echo $filter_name?>&page='+page,
	        success: function(html)
	        {
	            if(html)
	            {
	                $("#postswrapper").append(html);
	                $('div#loadmoreajaxloader').hide();
	            }else
	            {
	                $('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
	            }
	        }
	        });  
        }      
    }
});
</script>